
/*
'===============================================================================
'  Generated From - BLL_Component_Partial_Core.vbgen
'  
'  This object is partial class component representing a table in a database. It
'  contains core data access methods. Other partial classes should be used for 
'  implementing custom business logic. This class can be regenerated many times.
'  
'  Do not write custom business logic in this class as it will be overwritten 
'  next time the class is generated.
'
'  Version: 1.0
'  Date:	30/01/06
'  Summary: SelectOne, SelectAll, SelectAllWForeignKey, Insert, Update, Delete,
'  			DeleteAllWForeignKey, class for sorting.
'===============================================================================
*/
using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    [DataObjectAttribute]
	public partial class vwGeo_LocationWithAdministrativeDivisionDataComponent
    {
        
		/// <summary>
        /// Default constructor.
        /// </summary>
		public vwGeo_LocationWithAdministrativeDivisionDataComponent()
        {

        }

	
		/// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
		[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
		public List<vwGeo_LocationWithAdministrativeDivisionData> SelectAll(string sortExpression)
        {
            List<vwGeo_LocationWithAdministrativeDivisionData> listvwGeo_LocationWithAdministrativeDivisionData = new List<vwGeo_LocationWithAdministrativeDivisionData>();
            PlacementManager.DAL.vwGeo_LocationWithAdministrativeDivisionData_DAL o = new PlacementManager.DAL.vwGeo_LocationWithAdministrativeDivisionData_DAL();

            DataSet ds = o.SelectAll();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listvwGeo_LocationWithAdministrativeDivisionData.Add(new vwGeo_LocationWithAdministrativeDivisionData((int)row["GeoLocationID"], (int)row["UniqueFeatureID"], (int)row["UniqueNameID"], (double)row["Latitude"], (double)row["Longitude"], (int)row["DMS_Latitude"], (int)row["DMS_Longitude"], (string)row["UniversalTransverseMercator"], (string)row["JointOperationsGraphic"], (string)row["FeatureClassification"], (string)row["FeatureDesignation"], (string)row["CountryCode"], (int)row["CountryID"], (string)row["AdministrativeDivision"], (int)row["AdministrativeDivisionID"], (string)row["ShortName"], (string)row["SortName"], (string)row["FullName"], (DateTime)row["DateCreated"], (string)row["DivisionName"], (string)row["DivisionPostalAbbreviation"]));
            }
			
			if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listvwGeo_LocationWithAdministrativeDivisionData.Sort(new vwGeo_LocationWithAdministrativeDivisionDataComparer(sortExpression));
            return listvwGeo_LocationWithAdministrativeDivisionData;
        }
	}
	
	public class vwGeo_LocationWithAdministrativeDivisionDataComparer : IComparer<vwGeo_LocationWithAdministrativeDivisionData>
    {
        private string _sortColumn;
        private bool _reverse;

        public vwGeo_LocationWithAdministrativeDivisionDataComparer(string sortExpression)
        {
            _reverse = sortExpression.ToLowerInvariant().EndsWith(" desc");
            if (_reverse)
            {
                _sortColumn = sortExpression.Substring(0, sortExpression.Length - 5);
            }
            else
            {
                _sortColumn = sortExpression;
            }
        }

        public int Compare(vwGeo_LocationWithAdministrativeDivisionData a, vwGeo_LocationWithAdministrativeDivisionData b)
        {
            int retVal = 0;
            switch (_sortColumn)
            {
				case "GeoLocationID":
					retVal = String.Compare(a.GeoLocationID.ToString(), b.GeoLocationID.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "UniqueFeatureID":
					retVal = String.Compare(a.UniqueFeatureID.ToString(), b.UniqueFeatureID.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "UniqueNameID":
					retVal = String.Compare(a.UniqueNameID.ToString(), b.UniqueNameID.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "Latitude":
					retVal = String.Compare(a.Latitude.ToString(), b.Latitude.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "Longitude":
					retVal = String.Compare(a.Longitude.ToString(), b.Longitude.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "DMS_Latitude":
					retVal = String.Compare(a.DMS_Latitude.ToString(), b.DMS_Latitude.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "DMS_Longitude":
					retVal = String.Compare(a.DMS_Longitude.ToString(), b.DMS_Longitude.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "UniversalTransverseMercator":
					retVal = String.Compare(a.UniversalTransverseMercator.ToString(), b.UniversalTransverseMercator.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "JointOperationsGraphic":
					retVal = String.Compare(a.JointOperationsGraphic.ToString(), b.JointOperationsGraphic.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "FeatureClassification":
					retVal = String.Compare(a.FeatureClassification.ToString(), b.FeatureClassification.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "FeatureDesignation":
					retVal = String.Compare(a.FeatureDesignation.ToString(), b.FeatureDesignation.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "CountryCode":
					retVal = String.Compare(a.CountryCode.ToString(), b.CountryCode.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "CountryID":
					retVal = String.Compare(a.CountryID.ToString(), b.CountryID.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "AdministrativeDivision":
					retVal = String.Compare(a.AdministrativeDivision.ToString(), b.AdministrativeDivision.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "AdministrativeDivisionID":
					retVal = String.Compare(a.AdministrativeDivisionID.ToString(), b.AdministrativeDivisionID.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "ShortName":
					retVal = String.Compare(a.ShortName.ToString(), b.ShortName.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "SortName":
					retVal = String.Compare(a.SortName.ToString(), b.SortName.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "FullName":
					retVal = String.Compare(a.FullName.ToString(), b.FullName.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "DateCreated":
					retVal = String.Compare(a.DateCreated.ToString(), b.DateCreated.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "DivisionName":
					retVal = String.Compare(a.DivisionName.ToString(), b.DivisionName.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "DivisionPostalAbbreviation":
					retVal = String.Compare(a.DivisionPostalAbbreviation.ToString(), b.DivisionPostalAbbreviation.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;

            }
            return (retVal * (_reverse ? -1 : 1));
        }
    }
}
	
